package thread.threadexecutor;

import com.google.common.collect.Lists;
import org.omg.CORBA.TIMEOUT;

import java.lang.reflect.Parameter;
import java.util.List;
import java.util.concurrent.*;

public abstract class ThreadPoolExecutorDemo {

  // coresize 1 maxsiz 2 队列 2
  public static ExecutorService executorService = new ThreadPoolExecutor(1
          , 2
          , 60
          , TimeUnit.SECONDS
          , new ArrayBlockingQueue<>(2));


  public static void main(String[] args) {
    //测试一下线城池的 RejectedExecutionException 拒绝策略
    for (int i = 0; i < 10; i++) {
      System.out.println(i + 1);
      Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
          try {
            //等待十秒
            Thread.sleep(1000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      });
      executorService.submit(thread);
    }

  }

}
